#ifndef __MSG_CMN_H__
#define __MSG_CMN_H__

#include <stdint.h>

#ifdef __cplusplus
extern "C"{
#endif

#define  debug_dump_buffer(num, str)  {                                \
    if( (num) > 0 )                                                    \
    {                                                                  \
        int32_t pst = 0;                                               \
        printf("DUMP BIN(%d): ", num);                                 \
        for( ; pst < num - 1; ++pst )                                  \
            printf("0x%02X,", *((unsigned char*)str + pst));           \
        printf("0x%02X\n", *((unsigned char*)str + num - 1));          \
    }                                                                  \
}

#define MSGQ_FTOK_ID                   0x12

#define MSG_TYPE_COMMAND               0
#define MSG_TYPE_TICK                  1
#define MSG_TYPE_INTERNAL              2

/* Message queue type must > 0, one type value per program */
#define MSGQ_TYPE_MSG                  0x01  /* detector program */      
#define MSGQ_TYPE_INT                  0x02  /* interface program */
#define MSGQ_TYPE_SMS                  0x03  /* sms program */
#define MSGQ_TYPE_CLI                  0x04  /* cli program */
#define MSGQ_TYPE_FWM                  0x05  /* fwmgr program */
#define MSGQ_TYPE_REPORT               0x07  /*report program */

#define get_mtype(mod_id)              (((mod_id)&0xFF00)>>8)

#define MODULE_SYSTEM                  0x0100
#define MODULE_MESSAGE                 0x0101
#define MODULE_CONSOLE                 0x0102
#define MODULE_CONFIGM                 0x0103
#define MODULE_DATAPRO                 0x0104
#define MODULE_DATAM                   0x0105
#define MODULE_WIFI                    0x0106
#define MODULE_PM                      0x0107
#define MODULE_SCANNER                 0x0108
#define MODULE_GSM_CAP                 0x0109
#define MODULE_PA                      0x010A
#define MODULE_GPS                     0x010B
#define MODULE_EUTRAN_SNIFFER          0x010C
#define MODULE_CDMA_CAP                0x010D
#define MODULE_SYSMONITOR              0x010E
#define MODULE_LOG_SERVER              0x010F
#define MODULE_WCDMA_CAP               0x0110
#define MODULE_TDSCDMA_CAP             0x0111
#define MODULE_WIFI_BOARD              0x0112
#define MODULE_GPS_BOARD			   0x0113

#define MODULE_INTF                    0x0200

#define MODULE_SMS                     0x0300

#define MODULE_CLI                     0x0400

#define MODULE_FWMGR                   0x0500

#define MODULE_DATA_REPORT             0x0700

typedef struct tagMSGHEADER {
    long     mType;
    uint16_t dstID;
    uint16_t srcID;
    uint16_t msgType;
    uint16_t msgLength;
} MSGHEADER, *PMSGHEADER;

#ifdef __cplusplus
}
#endif

#endif //__MSG_CMN_H__
